/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import Dao.AlunoDao;
import Dao.AlunoDaoImplJPA;
import Dao.DisciplinaDao;
import Dao.DisciplinaDaoImplJPA;
import Dao.HistoricoDao;
import Dao.HistoricoDaoImplJPA;
import Pojo.Aluno;
import Pojo.Disciplina;
import Pojo.Historico;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;


/**
 *
 * @author thiago
 */
public class HistoricoDaoImplJPATeste {
    
    public HistoricoDaoImplJPATeste() {
    }
    
    @BeforeClass
    public static void setUpClass() {
    }
    
    @AfterClass
    public static void tearDownClass() {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }
    // TODO add test methods here.
    // The methods must be annotated with annotation @Test. For example:
    //
    // @Test
    // public void hello() {}
    
     @Test
    public void inserirDaCerto(){
       HistoricoDao historicoDao = new HistoricoDaoImplJPA();
        Historico historico = new Historico(5,75,14);
        assertTrue(historicoDao.inserir(historico));
    }
           
    @Test
    public void alterarDaCerto(){
        HistoricoDao historicoDao = new HistoricoDaoImplJPA();
        Historico historico = new Historico(5,90,8);
        assertTrue(historicoDao.alterar(historico));
    }
    
    @Test
    public void alterarDaErrado(){
        HistoricoDao historicoDao = new HistoricoDaoImplJPA();
        Historico historico = new Historico(20,90,8);
        assertFalse(historicoDao.alterar(historico));
    }
    
    @Test
    public void removerDaCerto(){
        HistoricoDao historicoDao = new HistoricoDaoImplJPA();
        Historico historico = new Historico(5,75,14);
        assertTrue(historicoDao.remover(historico));
    }
    
    @Test
    public void removerDaErrado(){
        HistoricoDao historicoDao = new HistoricoDaoImplJPA();
        Historico historico = new Historico(6,50,8);
        assertFalse(historicoDao.remover(historico));
    }
    
    @Test
    public void pesquisarPorAlunoEDisciplinaDaCerto(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        Aluno aluno = new Aluno(1,"Thiago","09989403643");
        alunoDao.inserir(aluno);
        HistoricoDao historicoDao = new HistoricoDaoImplJPA();
        alunoDao.inserir(aluno);
        DisciplinaDao disciplinaDao = new DisciplinaDaoImplJPA();
        Disciplina disciplina = new Disciplina(1,"AEDS","algoritmos",72);
        disciplinaDao.inserir(disciplina);
        assertNotNull(historicoDao.pesquisarPorAlunoEDisciplina(aluno,disciplina));
    }

    @Test
    public void pesquisarPorAlunoEDisciplinaDaErrado(){
        Aluno aluno = new Aluno(10,"Thiago","09989403643");
        Disciplina disciplina = new Disciplina(2,"AEDS1","ementa",72);
        HistoricoDao historicoDao = new HistoricoDaoImplJPA();
        assertNull(historicoDao.pesquisarPorAlunoEDisciplina(aluno, disciplina));
    }
    
}